<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>

        function fnMyalert() {
            alert('哈啊哈');
        }
        // fnMyalert();

        // 创建执行一次的定时器
        var timer01 = setTimeout(fnMyalert, 1000);

        //关闭只执行一次的定时器
        clearTimeout(timer01);

        //创建反复执行的定时器
        var time02 = setInterval(fnMyalert, 2000);

        //关闭反复执行的定时器
        clearInterval(timer02);

    </script>
</head>
<body>

</body>
</html>